package com.hongkzh.www.look.enterprise.presenter;

import android.util.Log;

import com.hongkzh.www.look.model.bean.AttenedBean;
import com.hongkzh.www.look.model.bean.MyAttendBean;
import com.hongkzh.www.other.api.UrlWrapper;
import com.hongkzh.www.other.okhttp.CallBackUtil;
import com.hongkzh.www.other.okhttp.OkhttpUtil;
import com.hongkzh.www.look.view.iview.MyAttendIView;
import com.hongkzh.www.presenter.BasePresenter;

import okhttp3.Call;

import static com.hongkzh.www.other.api.Api.FOLLOWDELETE;
import static com.hongkzh.www.other.api.Api.FOLLOWLIST;

/**
 * 关注
 */
public class MyAttendPresenter extends BasePresenter<MyAttendIView> {

    private boolean isLastPage;


    // 获取我的关注列表
    public void GetMyAttendList(String loginUid, String pageNum) {
        UrlWrapper wrapper = UrlWrapper.getInstance();
        wrapper.addParameter("loginUid", loginUid);
        wrapper.addParameter("pageNumber", pageNum);
        String url = FOLLOWLIST + wrapper.getRequestURL();

        OkhttpUtil.okHttpPost(url, new CallBackUtil<MyAttendBean>() {
            @Override
            public void onFailure(Call call, Exception e) {

            }

            @Override
            public void onResponse(MyAttendBean attendBean) {
                isLastPage = attendBean.getData().isLastPage();
                if (isLastPage) getIView().onLastPage(isLastPage);
                getIView().onShowMyAttendList(attendBean);
            }
        });

    }


    // 删除/取消关注
    // 取消关注
    public void GetFollowDelete(String loginUid, String followUserId) {

        UrlWrapper urlWrapper = UrlWrapper.getInstance();
        urlWrapper.addParameter("loginUid", loginUid);
        urlWrapper.addParameter("followUserId", followUserId);
        String url = FOLLOWDELETE + urlWrapper.getRequestURL();
        Log.i("取消关注的url===", url);

        OkhttpUtil.okHttpPost(url, new CallBackUtil<AttenedBean>() {
            @Override
            public void onFailure(Call call, Exception e) {

            }

            @Override
            public void onResponse(AttenedBean response) {
                getIView().deleteMyAttendList(response);
            }
        });
    }


}
